package com.arelikebrothers.demo.java8.stream;

/**
 * Created by qiuzhongrun on 01/05/2017.
 */
public class Person {
    private String name;
    private Gender gender;
    private int age;

    public Person(String name, Gender gender, int age) throws Exception {
        this.setAge(age);
        this.setName(name);
        this.setGender(gender);
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws Exception {
        if (age<1 || age>150)
        {
            throw new Exception("No one can live to "+age);
        }

        this.age = age;
    }

    public Gender getGender() {
        return gender;
    }

    public void setGender(Gender gender) {
        this.gender = gender;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "["+name+", "+gender+", "+age+"]";
    }
}
